<script type="text/javascript" src="public/register.js"></script>
<script type="text/javascript" src="public/types.js"></script>
<div id="main-register">
	<%
		String reason = request.getParameter("reason");
		if ("invalid".equals(reason))
			out.print("<h2 class=\"errorText\">One or more of the details were invalid. please try again.</h2>");
	%>
	<form id="registrationForm" method="post" action="#">
		<div style="text-align:left;position:absolute;left:37%;">
			<fieldset>
				<legend>Registration:</legend>
				<table>
					<tr>
						<td><label for="username">username:</label></td>
						<td><input type="text" name="username" id="username" size="40" maxlength="32" onkeypress="return (isNumberKey(event) || isLetterKey(event));" onkeydown="clearError('usernameText');" /></td>
						<td id="usernameText" class="errorText"></td>
					</tr>
					<tr>
						<td><label for="password">Password:</label></td>
						<td><input type="password" name="password" id="password" size="40" maxlength="32" onkeypress="return isPasswordKey(event);" onkeydown="clearError('passStrength');" onkeyup="checkPasswordStrength(this.value); checkConfirm();" /></td>
						<td id="passStrength"></td>
					</tr>
					<tr>
						<td><label for="confirm">Confirm:</label></td>
						<td><input type="password" name="confirm" id="confirm" size="40" maxlength="32" onkeypress="return isPasswordKey(event);" onkeyup="checkConfirm();" /></td>
						<td id="confirmText" class="errorText"></td>
					</tr>
					<tr>
						<td><label for="name">Full name:</label></td>
						<td><input type="text" name="name" id="name" size="40" maxlength="32" onkeypress="return isNameKey(event);" onkeydown="clearError('nameText');" /></td>
						<td id="nameText" class="errorText"></td>
					</tr>
					<tr>
						<td><label for="role">User type:</label></td>
						<td><select name="role" id="role" onchange="avdVisibility();" onkeyup="avdVisibility(); checkRequiredFields();">
							<option value="student">Student</option>
							<option value="administrator">Administrator</option>
						</select></td>
					</tr>
					</table>
					<table id="adminVeriBlock" style="display: none;">
					<tr>
						<td><label for="adminVeri">Administrator verification code:</label></td>
					</tr>
					<tr>
						<td><input type="password" name="adminVeri" id="adminVeri" size="40" maxlength="32" onkeypress="return isPasswordKey(event);" onkeydown="clearError('veriText');" /></td>
						<td id="veriText" class="errorText"></td>
					</tr>
				</table>
			</fieldset>
			<br />
			<fieldset>
				<legend>Extra details:</legend>
				<table>
					<tr>
						<td><label for="address">Address:</label></td>
						<td><input type="text" name="address" id="address" size="40" maxlength="256" /></td>
					</tr>
					<tr>
						<td><label for="phone">Phone:</label></td>
						<td><input type="text" name="phone" id="phone" size="40" maxlength="12" onkeypress="return isNumberKey(event);" /></td>
					</tr>
				</table>
			</fieldset>
			<br />
			<input type="submit" value="Submit!" />
		</div>
	</form>
	<script type="text/javascript">
		avdVisibility();
		setCheckAndPostFormToServletWithCompleteFunc('registrationForm', 'public/checkRegistration', checkForm, function(xhr) {if (xhr.status == 200) $('#homeLink').click(); else loadPage('public/register.jsp?reason=invalid');});
	</script>
</div>
